
#ifndef SMA_FRAME_H
#define SMA_FRAME_H

#include "smaAPI.h"

#define DEVICE_ID_MCP 0x10
#define DEVICE_ID_VSP 0x20
#define DEVICE_ID_API 0x30

typedef struct _SmaFrameHeader
{
	unsigned char src_id;
	unsigned char dst_id;
	unsigned long frame_id;
	unsigned long sent_time;
	unsigned char cmd_type;
	unsigned short cmd_code;
} SmaFrameHeader;

void smaPackDword(unsigned char *buff, unsigned long dword);
void smaPackWord(unsigned char *buff, unsigned short word);
unsigned long smaUnpackDword(const unsigned char *buff);
unsigned short smaUnpackWord(const unsigned char *buff);

int smaPackDataFrame(unsigned long buff_size,
					 unsigned char *buff,
					 const SmaFrameHeader *header,
					 unsigned long send_len,
					 const unsigned char *send_data);

int smaUnpackDataFrame(unsigned long buff_len,
					   const unsigned char *buff,
					   SmaFrameHeader *header,
					   unsigned long recv_size,
					   unsigned long *recv_len,
					   unsigned char *recv_data);

unsigned long smaCalculateFrameSize(unsigned long data_len);

void smaPackJointCfg(unsigned char *buff, const SmaJointCfg *cfg);
void smaUnpackJointCfg(const unsigned char *buff, SmaJointCfg *cfg);

void smaUnpackJointData(const unsigned char *buff, double data_array[6]);

void smaUnpackMcpStatus(const char *buff, SmaMcpStatus *status);

void smaPackPose(unsigned char *buff, const SmaPose *pose);
void smaUnpackPose(const unsigned char *buff, SmaPose *pose);

void smaUnpackImage(const unsigned char *buff, SmaImage *image);

void smaUnpackPoint2Df(const unsigned char *buff, SmaPoint2Df *point);

unsigned long smaUnpackFeature(const unsigned char *buff, unsigned long size, SmaFeatures *feature);

unsigned long smaUnpackMatch(const unsigned char *buff, unsigned long size, SmaMatches *match);

void smaUnpackPoint3Df(const unsigned char *buff, SmaPoint3Df *point);

unsigned long smaUnpackTargetModel(const unsigned char *buff, unsigned long size, SmaTargetModel *model);

void smaPackPath(unsigned char *buff, const SmaPath *path);
unsigned long smaUnpackPath(const unsigned char *buff, unsigned long size, SmaPath *path);



#endif /* SMA_FRAME_H */

